#include <at89c51RC2.h>
#include <Timer0.h>
#include <Delay.h>


sbit DA=P2^1;

unsigned char Counter,Compare;
unsigned char i;

void main()
{

	Timer0_Init();
	while(1)
	{
		for(i=0;i<100;i++)
		{
			Compare=i;
			Delay(1);
		}
		for(i=100;i>0;i--)
		{
			Compare=i;
			Delay(1);
		}
	}
}

void Timer0_Routine() interrupt 1  //溢出时中断
{
	TL0 = 0xAE;		
	TH0 = 0xFB;
	Counter++;
	Counter%=100;    //Counter到100了
	if(Counter<Compare)
	{
		DA=1;
	}
	else
	{
		DA=0;
	}
}